//
//  MTDViewController.m
//  Matador
//
//  Created by leaf on 15/10/4.
//  Copyright © 2015年 MicroGolds. All rights reserved.
//

#import "MTDViewController.h"

@interface MTDViewController ()

@end

@implementation MTDViewController

#pragma mark - Init
- (instancetype)init {
    self = [super init];
    if (self) {
        _forceHideBackButton = NO;
    }
    
    return self;
}
#pragma mark - Methods
- (void)popViewController {
    [self.navigationController popViewControllerAnimated:YES];
}
#pragma mark - Common Properties
- (UIStatusBarStyle)preferredStatusBarStyle {
    return UIStatusBarStyleLightContent;
}
#pragma mark - View
- (void)viewDidLoad {
    [super viewDidLoad];
    // Do any additional setup after loading the view.
    self.edgesForExtendedLayout = UIRectEdgeNone;
    self.automaticallyAdjustsScrollViewInsets = NO;
    
    self.view.backgroundColor = [UIColor whiteColor];
    
    if (!_forceHideBackButton) {
        UIViewController *rootViewController = [self.navigationController.viewControllers objectAtIndex:0];
        
        if (rootViewController && ![rootViewController isEqual:self]) {
            UIButton *view = [UIButton buttonWithType:UIButtonTypeCustom];
            view.frame = CGRectMake(0, 0, 42, 30);
            [view setImage:[UIImage imageNamed:@"nav_back_btn"] forState:UIControlStateNormal];
            [view addTarget:self action:@selector(popViewController) forControlEvents:UIControlEventTouchUpInside];
            [view setImageEdgeInsets:UIEdgeInsetsMake(0, -30, 0, 0)];
            
            UIBarButtonItem *item = [[UIBarButtonItem alloc] initWithCustomView:view];
            
            self.navigationItem.leftBarButtonItem = item;
            
        }
    }
}

@end
